package com.wang.springbootinit.controller.teacher;

import com.wang.springbootinit.common.BaseResponse;
import com.wang.springbootinit.common.ResultUtils;
import com.wang.springbootinit.model.dto.teacher.TeacherEditRequest;
import com.wang.springbootinit.model.vo.TeacherVO;
import com.wang.springbootinit.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


/**
 * 教师个人信息接口
 */
@RestController
@RequestMapping("/teacher/self")
public class TeacherInfoController {
    @Autowired
    private TeacherService teacherService;
    
    /**
     * 获取当前登录教师的个人信息
     */
    @GetMapping("/info")
    public BaseResponse<TeacherVO> getTeacherInfo(HttpServletRequest request) {
        TeacherVO teacherInfo = teacherService.getCurrentTeacherInfo(request);
        return ResultUtils.success(teacherInfo);
    }

    /**
     * 更新教师个人信息
     */
    @PostMapping("/update")
    public BaseResponse<Boolean> updateTeacherInfo(@RequestBody TeacherEditRequest updateRequest) {
        boolean result = teacherService.updateTeacherInfo(updateRequest);
        return ResultUtils.success(result);
    }
}
